﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Sharp.DataTransferObject;
using Sharp.Portal.Mvc;
using Sharp.Portal.Mvc.Models;
using Sharp.Portal.Mvc.Form;
using System.Web.Mvc;
using Sharp.Portal;
using Sharp.Portal.AdminLTE;

namespace Sharp.WebBooter.Areas.Platform.Models
{
    [ItemPage(OpenWith = OpenWith.Tile2Column)]
    public class OrgViewModel : ISharpForm
    {

        public OrgViewModel()
        {
            UI = new BSSharpFrom(this);
        }
        /// <summary>
        /// Id
        /// </summary>
        [HiddenInput]
        public Guid Id { get; set; }


        /// <summary>
        /// 编码
        /// </summary>
        [Display(Name = "编码", Order = 0), Required]
        public string Code { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        [Display(Name = "排序")]
        public int OrderIndex
        {
            get;
            set;
        }
        /// <summary>
        /// 名称
        /// </summary>
        /// <value>标题</value>
        [Required, Display(Name = "名称", Order = 1)]
        public string Title { get; set; }
        /// <summary>
        /// 简称
        /// </summary>
        [Display(Name = "简称", Order = 2)]
        public string Abbreviation { get; set; }
        /// <summary>
        /// 上级
        /// </summary>
        [Display(Name = "上级", Order = 3), CustomField(FieldType.OrgTreeList)]
        public System.Guid? ParentId { get; set; }
        /// <summary>
        /// ParentId 的数据源
        /// </summary>
        public zTreeNode ParentIdDataSource { get; set; }

        /// <summary>
        /// 区域编码
        /// </summary>
        [Display(Name = "所属区域", Order = 4), CustomField(FieldType.TreeList,"name","code", nameof(AreaCodeDataSource))]
        public string AreaCode { get; set; }

        public zTreeNode AreaCodeDataSource { get; set; }
        /// <summary>
        /// 坐标组
        /// </summary>
        [Display(Name = "坐标组", Order = 5)]
        public string Latlng { get; set; }
         

        /// <summary>
        /// 层级Id
        /// </summary>
        [Display(Name = "层级", Order = 6), CustomField(FieldType.DropDownList, "Title", "Id", "OrgLevelList")]
        public Guid? OrgLevelId { get; set; }


        /// <summary>
        /// 上面的数据源
        /// </summary>
        public IEnumerable<OrgLevelDTO> OrgLevelList { get; set; }

        /// <summary>
        /// 编制
        /// </summary>
        [Display(Name = "编制", Order = 5), RegularExpression(@"^[1-9]\d*$", ErrorMessage = "请输入自然数！")]
        public int? MaxHeadcount { get; set; }


        /// <summary>
        /// 备注
        /// </summary>
        /// <value>备注</value>
        [Display(Name = "备注", Order = 7), DataType(DataType.MultilineText)]
        public string Remark { get; set; }

        /// <summary>
        /// 为控件显示用的属性
        /// </summary>
        /// <![CDATA[<treegrid-@Model.Id treegrid-parent-@Model.ParentId>]]>
        public string Itemclass { get; set; }

        public SharpFrom UI { get; set; }

    }
}